/*
 * @ProjectName: 编程学习
 * @Copyright:   2019 HangZhou Yi Dev, Ltd. All Right Reserved.
 * @address:     https://yiyuery.github.io/
 * @date:        2019/5/20 20:57
 * @email:       xiazhaoyang@live.com
 * @description: 本内容仅限于编程技术学习使用，转发请注明出处.
 */
package com.example.template.pattern.state;

import lombok.Data;

/**
 * <p>
 *
 * </p>
 *
 * @author Yi
 * @version v1.0.0
 * @date 2019-09-08 11:58
 * @modificationHistory=========================逻辑或功能性重大变更记录
 * @modify By: {修改人} 2019-09-08
 * @modify reason: {方法名}:{原因}
 * ...
 */
@Data
public class TaskStateManagerContext {

    TaskState prepareState;
    TaskState finishedSate;
    TaskState directStopState;
    TaskState suspendState;
    TaskState runningState;

    private TaskState currentState;

    public static void main(String[] args) {
        TaskStateManagerContext context = new TaskStateManagerContext();
        TaskState prepareState = new PrepareState(context);
        //任务准备状态
        context.setCurrentState(prepareState);
        context.getCurrentState().handle();
        //任务运行状态
        context.getCurrentState().getStatus();
        //进行下一个状态
        context.getCurrentState().handle();
        //手动干预状态
        context.setCurrentState(new DirectStopState(context));
        context.getCurrentState().handle();
        //查询状态
        context.getCurrentState().getStatus();

        //Task Preparing...
        //>>>>> RunningState
        //Task running......
        //Task is stopping...
        //>>>>> FinishedSate
    }


}
